package thread;

import io.ISRDemo;

/**
 * 线程提供了一组获取自身相关信息的方法
 */
public class ThreadinfoDemo {
    public static void main(String[] args) {
        //以主线程为例
        Thread main = Thread.currentThread();
        //获取线程的名字
        String name = main.getName();
        System.out.println(name);

        //获取ID  唯一标识  id需要同时满足两个条件  非空且不重复
        //系统分配
        long id = main.getId();
        System.out.println(id);
        //获取线程的优先级,默认值是5.取值在1-10之间的整数
        int priority = main.getPriority();
        System.out.println(priority);
        //线程是否活着
        boolean aslive = main.isAlive();
        //线程是否为守护线程
        boolean daemon = main.isDaemon();
        //线程是否被中断
        boolean interrupted = main.isInterrupted();
        System.out.println("isAlive:"+aslive);
        System.out.println("isDaemon:"+daemon);
        System.out.println("isInterrupted:"+ interrupted);

    }
}
